package simtester.server

import org.springframework.dao.DataIntegrityViolationException

class TypeController {

    static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

    def index() {
        redirect(action: "list", params: params)
    }

	def list() {
		params.max = Math.min(params.max ? params.int('max') : 10, 100)
		[teamInstanceList: Team.list(params), teamInstanceTotal: Team.count()]
	}
	
    def create() {
        if (request.method == 'POST') {
            def type = new Type(name: params.name.toLowerCase())
            type.save()
			def typelist = type.list().collect { it.name }
            redirect(controller: 'user', action: 'create')
        }
    }

    def delete() {
        def type = Type.get(params.id)
        type.delete()
		return
    }
}
